#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector<int> findAnagrams(string s1, string s2) {
    vector<int> v, hash1, hash2;
    hash2.reserve(128);
    hash1.reserve(128);
    for (char ch : s2)
        hash2[ch]++;
    int left = 0, right = 0, size1 = s1.size(), size2 = s2.size();
    while (right < size1) {
        hash1[s1[right]]++;
        if (right - left + 1 == size2) {
            if (hash1 == hash2)
                v.push_back(left);
            hash1[s1[left]]--;
            left++;
        }
        right++;
    }
    return v;
}
int totalFruit(vector<int>& fruits) {
    int type = 0, right = 0, left = 0, size = fruits.size(), total = 0;
    vector<int> hash(size);
    while (right < size) {
        if (hash[fruits[right]] == 0)
            type++;
        hash[fruits[right]]++, right++;
        while (type > 2) {
            hash[fruits[left]]--;
            if (hash[fruits[left]] == 0)
                type--;
            left++;
        }
        total = max(total, right - left);
    }
    return total;
}
int main()
{
    vector<int> v;
    v = findAnagrams("cbaebabacd", "abc");
	return 0;
}
